﻿using System.Threading;

namespace LogManager.Utils.Threading
{
    public class SerializedSynchronizationContext : SynchronizationContext
    {
        private TaskQueue _taskQueue = new TaskQueue();

        public override void Post(SendOrPostCallback d, object state)
        {
            this._taskQueue.Queue(false, () => d.Invoke(state));
        }
    }

    public class SyncSynchronizationContext : SynchronizationContext
    {
        public override void Post(SendOrPostCallback d, object state)
        {
            d.Invoke(state);
        }
    }
}
